import subprocess


def cat(xinput):
    proc = subprocess.Popen(
        ['cat'],
        stdin=subprocess.PIPE,
        stdout=subprocess.PIPE,
    )
    proc.stdin.write((xinput + '\n').encode('utf8'))
    proc.stdin.flush()
    return proc


if '__main__' == __name__:
    
    xinput = """\
It’s also possible to create chains of parallel processes, just like 
UNIX pipelines, connecting the output of one child process to the 
input of another, and so on. Here’s a function that starts the openssl
command-line tool as a subprocess to generate a Whirlpool hash of 
the input stream. 我是中文。 I'm Chinese."""

    proc = cat(xinput)
    xstdout, xstderr = proc.communicate()
    print('stdout:', xstdout.decode() if xstdout is not None else None)
    print('stderr:', xstderr.decode() if xstderr is not None else None)
    